<?php
// $Id$

/**
 * Controller_Leavemessage 控制器
 */
class Controller_Leavemessage extends Controller_Abstract
{
	function actionIndex()
	{
	}
	
	//读留言
	function actionMessage()
	{
		$messagePrev = Leavemessage::messageGet();
		$this->_view['messagePrev']=$messagePrev;
	}
	
	//js
    function actionJs()
    {
    	
    }

    //写留言
    function actionMessageSet()
    {
    	$realname = $this->_context->get_post('realname');
    	$email = $this->_context->get_post('email');
    	$tel = $this->_context->get_post('tel');
    	$subject = $this->_context->get_post('subject');
    	$message = $this->_context->get_post('message');
		$message = iconv("UTF-8","UTF-8//IGNORE",$message);
		$createtime = time();
		//
		$session = $this->_context->session();
		$uid = $session['user_id'];
		$uname = $session['user_name'];
		//
		if(empty($realname))
		{
			//验证数据
		}else
		{
			try
			{
				$setResult = Leavemessage::messageSet($uid,$uname,$subject,$message,$realname,$email,$tel,$createtime);
				echo $setResult;
			}catch (Exception $ex)
			{
				echo 0;
			}
		}		
    }
    
    //删留言
	function actionMessageDelete()
	{
		$messageId = $this->_context->get_post('messageId');
		if(1===2)
		{
			//验证权限
		}else
		{
			try
			{
				$delResult = Leavemessage::messageDelete($messageId);
				echo $delResult;
			}catch (Exception $ex)
			{
				echo 0;
			}
		}
	}
    
	//改留言
    function actionMessageModify()
    {
    	$messageId = $this->_context->get_post('messageId');
    	$act = $this->_context->get_post('act');
    	if("status"==$act)
    	{
    		$modResult = Leavemessage::messageModifyStatus($messageId);
    	}
    }

    
    
}


